<template>
  <div class="addedSuccessfully">
      <Nav></Nav>
      <div class="writing_right">
          <div class="addedSuccessfullyTitleList">
              <div class="TitleList_padding">
                  <div class="TitleList_top">
                      <div class="parametersettings_content_top">
                          <div class="content_top_logo"><img src="@a/img/logo2.png" /></div>
                          <span class="content_top_span1"></span>
                          <div class="content_top_icon"><img src="@a/img/sv13.svg" /></div>
                          <span class="content_top_span2"></span>
                          <div class="content_top_logo"><img :src="demo_logo" /></div>
                      </div>
                      <div class="TitleList_top_title">
                          <span>AI-DOG</span>与<span>[{{ demo_name }}]</span>建立数据通道
                      </div>
                  </div>
              </div>

              <div class="emailmo_step">
                  <div class="emailmo_step_list on">
                      <div class="step_list_icon">1</div>
                      <div class="step_list_title">安装插件</div>
                  </div>
                  <span></span>
                  <div class="emailmo_step_list on">
                      <div class="step_list_icon">2</div>
                      <div class="step_list_title">网站信息</div>
                  </div>
                  <span></span>
                  <div class="emailmo_step_list on">
                      <div class="step_list_icon">3</div>
                      <div class="step_list_title">添加成功</div>
                  </div>
              </div>

              <div class="addedSuccessfully_content">
                  <div class="addedSuccessfully_content_title">
                    <div class="content_title_dd">🏆成功建立站点🎈</div>
                    <div class="content_title_dt">现在你可以根据词库发布写作任务，系统将根据任务设定自动化发布。</div>
                  </div>
                  <div class="addedSuccessfully_content_btn">
                    <router-link target="_blank"  :to="'/writing/myArticles?site_id='+$route.query.id" class="content_btn_list on">发布文章</router-link>
                    <router-link to="/writing/planTorelease" class="content_btn_list on">为此站点分配写作任务</router-link>
                    <router-link target="_blank"  :to="'/writing/siteManagement/InterfaceTest?id='+$route.query.id" class="content_btn_list">测试发布</router-link>	
					<router-link to="/writing/siteManagement" class="content_btn_list">返回我的站点</router-link>
									
                  </div>
              </div>
          </div>
      </div>
  </div>
</template>

<script>
  import Nav from "@c/common/nav/nav";

  export default {
      name: "parametersettings",
      data() {
          return {
              demo_name: '',
              demo_logo: '',
              isShow: true ,
              testData:{
                title: '',
                url: '',
                catid: '',
                newstime: '',
                content: ''
              },
              info: {

              },
              site_classes: [],
              showPreview: false,


              pickerOptions: {
              disabledDate(time) {
                  return time.getTime() > Date.now();
              },
              shortcuts: [{
                  text: '今天',
                  onClick(picker) {
                  picker.$emit('pick', new Date());
                  }
              }, {
                  text: '昨天',
                  onClick(picker) {
                  const date = new Date();
                  date.setTime(date.getTime() - 3600 * 1000 * 24);
                  picker.$emit('pick', date);
                  }
              }, {
                  text: '一周前',
                  onClick(picker) {
                  const date = new Date();
                  date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                  picker.$emit('pick', date);
                  }
              }]
              },
              value1: '',
              value2: '',
              value3: '',
              value4: '',
              value5: '',
              value6: '',
              value7: '',
              value8: '',
              siteValue: '',
              siteSelect: '',
              urlValue: '',
              textarea1: '',
              textarea2: '',
          };
      },
      components: {
          Nav
      },
      methods:{
        testPush(){
            let that = this;
            that.axios.post('/api/site/testPush', {
              'site' : that.info,
              'data' : that.testData
            }).then(res => {
              if(res.code === 1) {
                that.$msgbox('测试发布成功','提示')
              }else{
                that.$msgbox(res.result, '测试发布失败')
              }
            })
        },
        toTest(){
         let that = this;
          this.axios.post('/api/site/getClassesByUrl', {
            url:  that.info.website + that.info.column_interface
          }).then(res => {
            if(res.code === 1) {

              that.site_classes = res.result
              that.testData.url = that.info.website + that.info.publishing_interface
              that.showPreview = true

            }else{
              that.$msgbox(res.result, '获取栏目错误')
            }
          })

        },
        save(){
          let that = this;
          that.axios.post('/api/site/add', that.info).then(res => {
            if(res.code === 1) {
              this.$router.push({path:'/writing/siteManagement'})
            }
          })
        },
      goOff(){
          this.$router.go(-1);
      },
      advancedClick(){
          this.advanced = !this.advanced
        },


        getData(){
          let that = this;
          let id = this.$route.query.id
          if(id){
            that.axios.get('/api/site/getSite', {
              params: {
                id
              }
            }).then(res => {
              if(res.code === 1) {
                that.info = res.result;
                let demo_id = res.result.site_demo_id
                that.axios.get('/api/site/getDemo', {
                  params: {
                    id: demo_id
                  }
                }).then(res => {
                  if(res.code === 1) {
                    that.demo_name = res.result.name;
                    that.demo_logo= res.result.logo_image
                  }
                })
              }
            })
          }


        }
      },
      created() {
        this.getData()
      },
  }
</script>

<style>
@import "addedSuccessfully.css";
</style>
